package com.ruoyi.system.controller;

import java.util.HashMap;
import java.util.List;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.ruoyi.system.annotation.UserContext;
import com.ruoyi.system.domain.vo.UserData;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import com.alibaba.fastjson.JSON;
import com.ruoyi.common.core.domain.Orders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.OfflinePurchase;
import com.ruoyi.system.service.IOfflinePurchaseService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
import org.springframework.web.client.RestTemplate;
/**
 * 商品信息 ：与店铺关联Controller
 * 
 * @author wh
 * @date 2024-09-18
 */
@RestController
@RequestMapping("/offline_purchase")
public class OfflinePurchaseController extends BaseController
{
    @Autowired
    private IOfflinePurchaseService offlinePurchaseService;

    /**
     * 查询商品信息 ：与店铺关联列表
     */
    @RequiresPermissions("system:offline_purchase:list")
    @GetMapping("/list")
    public TableDataInfo list(OfflinePurchase offlinePurchase)
    {

        startPage();
        List<OfflinePurchase> list = offlinePurchaseService.selectOfflinePurchaseList(offlinePurchase);
        return getDataTable(list);
    }

    /**
     * 导出商品信息 ：与店铺关联列表
     */
    @RequiresPermissions("system:offline_purchase:export")
    @Log(title = "商品信息 ：与店铺关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OfflinePurchase offlinePurchase)
    {
        List<OfflinePurchase> list = offlinePurchaseService.selectOfflinePurchaseList(offlinePurchase);
        ExcelUtil<OfflinePurchase> util = new ExcelUtil<OfflinePurchase>(OfflinePurchase.class);
        util.exportExcel(response, list, "商品信息 ：与店铺关联数据");
    }

    /**
     * 获取商品信息 ：与店铺关联详细信息
     */
    @RequiresPermissions("system:offline_purchase:query")
    @GetMapping(value = "/{productId}")
    public AjaxResult getInfo(@PathVariable("productId") Long productId)
    {
        return success(offlinePurchaseService.selectOfflinePurchaseByProductId(productId));
    }



}
